package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.PreOrderBook;
import com.pgybook.db.entity.domain.PreOrderBookEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface PreOrderBookMapper {
    int countByExample(PreOrderBookEx example);

    int deleteByExample(PreOrderBookEx example);

    @Delete({
            "delete from preorderbook",
            "where PREORDERID = #{preorderid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long preorderid);

    @Insert({
            "insert into preorderbook (BOOKID, INSTANCEID, ",
            "CUSTID, LIBID, BOOKINTIME, ",
            "CRTTIME)",
            "values (#{bookid,jdbcType=BIGINT}, #{instanceid,jdbcType=BIGINT}, ",
            "#{custid,jdbcType=BIGINT}, #{libid,jdbcType=INTEGER}, #{bookintime,jdbcType=TIMESTAMP}, ",
            "#{crttime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "preorderid", before = false, resultType = Long.class)
    int insert(PreOrderBook record);

    int insertSelective(PreOrderBook record);

    List<PreOrderBook> selectByExample(PreOrderBookEx example);

    @Select({
            "select",
            "PREORDERID, BOOKID, INSTANCEID, CUSTID, LIBID, BOOKINTIME, CRTTIME",
            "from preorderbook",
            "where PREORDERID = #{preorderid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    PreOrderBook selectByPrimaryKey(Long preorderid);

    int updateByExampleSelective(@Param("record") PreOrderBook record, @Param("example") PreOrderBookEx example);

    int updateByExample(@Param("record") PreOrderBook record, @Param("example") PreOrderBookEx example);

    int updateByPrimaryKeySelective(PreOrderBook record);

    @Update({
            "update preorderbook",
            "set BOOKID = #{bookid,jdbcType=BIGINT},",
            "INSTANCEID = #{instanceid,jdbcType=BIGINT},",
            "CUSTID = #{custid,jdbcType=BIGINT},",
            "LIBID = #{libid,jdbcType=INTEGER},",
            "BOOKINTIME = #{bookintime,jdbcType=TIMESTAMP},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP}",
            "where PREORDERID = #{preorderid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(PreOrderBook record);
}
